<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
import OrderEvent from "@/mixin/orderEvent";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
    OrderEvent,
    Vue.prototype.$vFN.Utils,
  ],
  components: {},
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "admin/order/pageOrderRights",
      },
      isIndeterminate: false,
      checkAll: false,
      // 表格数据
      tableData: [],
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "品牌名称",
            prop: "name",
            type: "",
          },
          {
            label: "绑定商品数",
            prop: "productCount",
            type: "",
          },
        ],
      },

      mixinTable_tableSearchData: {
        orderNo: "",
      },

      // 列表高级查询参数
      mixinTable_tableSearchSenior: {
        // 手机号
        mobile: {
          type: String,
          value: "",
          default: "",
        },

        // 售后订单号
        rightNo: {
          type: String,
          value: "",
          default: "",
        },

        // 商品名称
        productName: {
          type: String,
          value: "",
          default: "",
        },

        // 申请售后开始时间
        createdTimeStartStr: {
          type: String,
          value: null,
          default: null,
        },

        // 申请售后结束时间
        createdTimeEndStr: {
          type: String,
          value: null,
          default: null,
        },

        // 售后类型
        rightType: {
          type: Number,
          value: null,
          default: null,
        },

        // 售后状态
        rightStatus: {
          type: Number,
          value: null,
          default: null,
        },
      },

      // 售后类型数组
      rightTypeArr: [
        {
          label: "全部",
          value: null,
        },
        {
          label: "退款",
          value: 1,
        },
        {
          label: "退货退款",
          value: 2,
        },
      ],

      //  售后状态数组
      rightStatus: [
        [
          {
            label: "全部",
            value: null,
          },
        ],
        [
          {
            label: "全部",
            value: null,
          },
          {
            label: "待处理",
            value: 1,
          },
          {
            label: "处理中",
            value: 2,
          },
          {
            label: "已完成",
            value: 3,
          },
          {
            label: "已取消",
            value: 4,
          },
        ],
        [
          {
            label: "全部",
            value: null,
          },
          {
            label: "待处理",
            value: 1,
          },
          {
            label: "商家同意",
            value: 2,
          },
          {
            label: "买家退货",
            value: 3,
          },
          {
            label: "处理中",
            value: 4,
          },
          {
            label: "已完成",
            value: 5,
          },
          {
            label: "已取消",
            value: 6,
          },
        ],
      ],
    };
  },
  methods: {
    // 打开添加/修改
    editBoxOpen(params_) {
      Edit.init({
        mixinEdit_editType: params_.type,
        id: params_.id,
        onSuccess: (res) => {
          this.mixinTable_refreshData();
        },
      });
    },
    handleCheckAllChange(val) {
      let _list = [];
      if (val) {
        this.tableData.forEach((item) => {
          _list.push(item.id);
        });
      }
      this.mixinTable_selectTableData = _list;
      this.isIndeterminate = false;
    },
    clearSelection() {
      this.isIndeterminate = false;
      this.checkAll = false;
      this.mixinTable_selectTableData = [];
    },
    handleCheckedChange(value) {
      console.error(value);
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.tableData.length;
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.tableData.length;
    },
    // 时间戳转换
    timeStampConversion(timeStamp) {
      return this.$vFN.Utils.timestampToDate("yyyy-MM-dd HH:mm:ss", timeStamp);
    },

    // 选择了售后类型
    rightTypeChange(e) {
      console.log(e);
      this.mixinTable_tableSearchSenior.rightStatus.value = null;
      this.mixinTable_refreshData();
    },

    // 选择了售后状态
    rightStatusChange(e) {
      console.log(e);
      this.mixinTable_refreshData();
    },

    // 初始化
    async init() {
      // 刷新表格数据，此方法扩展时可重写
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>